package com.ricchieri.lazymodel;

import org.primefaces.model.ScheduleModel;

import com.ricchieri.common.CustomScheduleEvent;
import com.ricchieri.filter.ScheduleCharterFilter;
import com.ricchieri.service.interf.IScheduleCharterService;

public class ScheduleStatusLazyDataModel extends ScheduleLazyModel {
	private static final long serialVersionUID = 5116660762509725595L;

	public ScheduleStatusLazyDataModel(
			IScheduleCharterService scheduleCharterService,
			ScheduleCharterFilter scheduleCharterFilter,
			ScheduleModel scheduleModel) {
		super(scheduleCharterService, scheduleCharterFilter, scheduleModel);
	}

	@Override
	public String obtainStyle(CustomScheduleEvent customEvent) {
		int capacity = customEvent.getScheduleCharter().getCharter().getPlaces() - customEvent.getScheduleCharter().getQuantityReserved();
		
		if(capacity == 0){
			return "old-event";
		}else if(capacity <= 3){
			return "red-event";
		}else if(capacity <= 15){
			return "yellow-event";
		}else{
			return "green-event";
		}
	}

}
